package com.gm.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gm.dao.UserMapper;
import com.gm.entity.User;
import com.gm.service.UserService;

@Service(value = "userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper<User> userMapper;

    @Override
    public Integer insertSelective(User user) throws Exception {
        return this.userMapper.insertSelective(user);
    }

    @Override
    public Integer insertBatch(List<User> user) throws Exception {
        return this.userMapper.insertBatch(user) ;
    }

    @Override
    public Integer deleteByPrimaryKey(Object id) {
        return this.userMapper.deleteByPrimaryKey(id);
    }

    public Integer deleteBatchByPrimaryKey(List<Object> ids) {
        return this.userMapper.deleteBatchByPrimaryKey(ids);
    }

    @Override
    public Integer updateByPrimaryKeySelective(User user) {
        return this.userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public User findById(Object id) {
        return (User) this.userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> selectByCondition(User user) {
        return (List<User>) this.userMapper.selectByCondition(user);
    }

    @Override
    public Integer selectCountByCondition(User user) {
        return  this.userMapper.selectCountByCondition(user);
    }

    @Override
    public List<User> getUserList() {
        return userMapper.getUserList();
    }

    @Override
    public void InsertUser(User user) {
        userMapper.InsertUser(user);
    }

    @Override
    public User getByIdUser(String usersId) {
        return userMapper.getByIdUser(usersId);
    }
    @Override
    public void roleupdate(User user) {
        userMapper.roleupdate(user);
    }

    @Override
    public String deleteUser(String usersId) {
        List deleteList=new ArrayList();
        String[] split = usersId.split(",");
        for (String split1: split) {
            deleteList.add(split1);
        }
        userMapper.deleteUser(deleteList);
        return "1";
    }
    @Override
    public int stopUser(User user) {
        return userMapper.stopUser(user);
    }
}
